/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.system.bajlam.code.beans;

 import java.io.Serializable;
import java.util.ArrayList;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.RowEditEvent;
 
@ManagedBean(name = "produc")
@SessionScoped
public class beanVentasTable implements Serializable {
 
    private static final long serialVersionUID = 1L;
    private String codigo;
    private Double descuento;
    private Integer cantidad;
    private Double precio;
    orderBeanVentasTable ordenar;
 
    public String getCodigo() {
        return codigo;
    }
 
    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }
 
    public Double getPrecio() {
        return precio;
    }
 
    public void setPrecio(Double precio) {
        this.precio = precio;
    }
 
    public Integer getCantidad() {
        return cantidad;
    }
 
    public void setCantidad(Integer cantidad) {
        this.cantidad = cantidad;
    }
 
    public Double getDescuento() {
        return descuento;
    }
 
    public void setDescuento(Double descuento) {
        this.descuento = descuento;
    }
    
    
    public orderBeanVentasTable getOrder() {
        return ordenar;
    }
 
    public void setOrder(orderBeanVentasTable order) {
        this.ordenar = order;
    }
    private static final ArrayList<orderBeanVentasTable> orderList = new ArrayList<orderBeanVentasTable>();
 
    public ArrayList<orderBeanVentasTable> getOrderList() {
        return orderList;
    }
 
    public String addAction() {
        orderBeanVentasTable orderitem = new orderBeanVentasTable(this.codigo, this.precio, this.cantidad,this.descuento);
        
        orderList.add(orderitem);
        
    codigo="";
    descuento=0.0;
    cantidad=0;
    precio=0.0;
        return null;
    }
    public void onEdit(RowEditEvent event) {  
        FacesMessage msg = new FacesMessage("Item Edited",((OrderBean) event.getObject()).getItem());  
        FacesContext.getCurrentInstance().addMessage(null, msg);  
    }  
       
    public void onCancel(RowEditEvent event) {  
        FacesMessage msg = new FacesMessage("Item Cancelled");   
        FacesContext.getCurrentInstance().addMessage(null, msg); 
        orderList.remove((OrderBean) event.getObject());
    }  
}